<template>
    <view>
        <uni-list>
            <uni-list-item
                v-for="(item, index) in pendingServiceItem"
                :key="index"
                showArrow
                @click="() => selectItem(item)"
                :clickable="true"
                :title="item.siName"
                :rightText="'剩余' + item.spSpqu + item.siUnit"
            >
            </uni-list-item>
            <u-empty v-if="pendingServiceItem.length === 0" text="暂无数据"> </u-empty>
        </uni-list>
    </view>
</template>

<script>
import { getCustomerPendingServiceItem } from "../../utils/api";
import { mapGetters } from "vuex";

export default {
    data() {
        return {
            pendingServiceItem: [],
        };
    },

    async onLoad(params) {
        let res = await getCustomerPendingServiceItem({ ciUuid: this.userInfo.ciUuid });
        if (res) {
            this.pendingServiceItem = res || [];
        }
    },

    computed: {
        ...mapGetters({
            userInfo: "personInfo/userInfo",
        }),
    },

    methods: {
        async selectItem(item) {
            uni.navigateTo({
                url: `my_service_item_source?siUuid=${item.siUuid}`,
            });
        },
    },
};
</script>

<style lang="scss" scoped></style>
